package cn.kgc.spring.jdbc.mapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @author: mosin
 * @version: v1.0  2022/4/26
 */
@Repository
public class AccountMapperImpl  implements  AccountMapper{
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public int addMoney(int id, int money) {

        String sql = "update account set money = money + ? where id = ?";
        int line = jdbcTemplate.update(sql,money, id);
        return line;
    }

    @Override
    public int subMoney( int id,int money) {
        String sql = "update account set money = money - ? where id = ?";
        int line = jdbcTemplate.update(sql, money,id) ;
        return line;
    }
}
